package com.simplerobot.robot.tieba;

import com.simplerobot.consume.Page;
import com.simplerobot.consume.PageConsume;
import com.simplerobot.robot.Spider;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.model.ConsolePageModelPipeline;

/**
 * Created by Administrator on 2016/5/12.
 */
public class TieBaPageModelPipeLine extends ConsolePageModelPipeline {
    private Spider tieBaSpider;
    private PageConsume pageConsume;

    public TieBaPageModelPipeLine(BaiduTieBaSpider baiduTieBaSpider, PageConsume pageConsume) {
        this.tieBaSpider = baiduTieBaSpider;
        this.pageConsume = pageConsume;
    }
    @Override
    public void process(Object o, Task task) {
        super.process(o,task);
        TieBa tieBa = (TieBa) o;
        Page<TieBa> page = new Page<>(tieBa);
        pageConsume.putPage(tieBaSpider.getSpiderName(),page);
    }
}
